from importlib import import_module
import threading
from time import sleep

torch = ""
finish = False


def count():
    global torch
    global finish
    while not finish:
        sleep(0.1)
    print("torch is finish")
    return torch.cuda.device_count()


def child_thread_func():
    global torch
    global finish
    torch = import_module('torch')
    print("get torch")
    finish = True


t1 = threading.Thread(target=child_thread_func)
t1.start()
